﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication3
{
    public partial class LoginSuccess : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(Request.QueryString.Get("token")) &&
                !string.IsNullOrWhiteSpace(Request.QueryString.Get("user")))
            {
                Session["user"] = Request.QueryString.Get("user");
                Session["token"] = Request.QueryString.Get("token");
            }
        }

        protected void loginout_Click(object sender, EventArgs e)
        {
            Session.Clear();
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("http://localhost:61881/");
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("appliation/json"));
            UserInfo user = new UserInfo()
            {
                AppKey = "aaa",
                AppSecret = "sss",
                UserName = "km",
                Password = "123456",
                Ip = "127.0.0.1",
            };
            HttpResponseMessage response = client.PutAsJsonAsync("api/sso/loginout", user).Result;
            if (response.IsSuccessStatusCode)
            {
                Response.Redirect("http://localhost:61756/login.aspx?checkonline=true");
            }
        }
    }
}